package com.mybase.app.fourBase;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.mybase.app.R;

/**
 * Created by happy_000 on 2014/12/1.
 */
public class FristActivity extends Activity implements OnClickListener {
    private TextView show;
    private EditText edit;
    private Button btn;
    private int requestCode = 2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.frist_layout);
        show = (TextView) findViewById(R.id.frist_show);
        edit = (EditText) findViewById(R.id.frist_edit);
        btn = (Button) findViewById(R.id.frist_btn);
        btn.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        String str = edit.getText().toString();
        Intent intent = new Intent(FristActivity.this, SecondActivity.class);
        intent.putExtra("key", str);
        Bundle bundle = new Bundle();//　　Bundle的底层是一个HashMap<String, Object
        bundle.putString("hello", "world");
        intent.putExtra("bundle", bundle);
        startActivityForResult(intent, requestCode);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == requestCode) {
            if (resultCode == RESULT_OK) {
                Bundle bundle = data.getExtras();
                String phoneno = bundle.getString("remark");
                show.setText("返回内容："+phoneno);
            }
        }
    }
}
